#include<stdio.h>
#include<string.h>
char* longestPalindrome(char* s) 
{
	int start = 0, end = 0, i = 0;
	int n = strlen(s);
	for (i = 0; i < n; i++) {
		int tmp_s = i, tmp_e = i;
		while (tmp_s >= 0 && tmp_e < n && s[tmp_s] == s[tmp_e])
		{
			tmp_s--; tmp_e++;
		}
		tmp_s++; tmp_e--;
		if (tmp_e - tmp_s > end - start) {
			start = tmp_s;
			end = tmp_e;
		}

		if (i + 1 < n && s[i] == s[i + 1]) {
			tmp_s = i; tmp_e = i + 1;
			while (tmp_s >= 0 && tmp_e < n && s[tmp_s] == s[tmp_e])
			{
				tmp_s--; tmp_e++;
			}
			tmp_s++; tmp_e--;
			if (tmp_e - tmp_s > end - start) {
				start = tmp_s;
				end = tmp_e;
			}
		}
	}
	s[end + 1] = '\0';
	return s + start;
}


int main()
{
	char s[] = "abbacaabbaac";
	longestPalindrome(s);
	return 0;
}